// ignore_for_file: file_names, must_be_immutable, constant_identifier_names, slash_for_doc_comments, avoid_unnecessary_containers, prefer_const_constructors, unnecessary_cast, sized_box_for_whitespace, prefer_function_declarations_over_variables, overridden_fields, annotate_overrides, prefer_const_literals_to_create_immutables, unnecessary_null_comparison, deprecated_member_use

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:mybase/base/abstract/IFFScaffold.dart';
import 'package:mybase/base/widget/layout/FFTextButton.dart';

typedef DeaultConfigFunc = Widget? Function(FFEventObj? obj);
typedef DeaultConfigRefreshFunc = String? Function(BuildContext context);

/**全局默认页面配置 */
class DeaultPageConfig {
  // 单例公开访问点
  factory DeaultPageConfig() => _sharedInstance();

  // 静态、同步、私有访问点
  static DeaultPageConfig _sharedInstance() {
    return _instance;
  }

  // 静态私有成员，没有初始化
  static final DeaultPageConfig _instance = DeaultPageConfig._();

  // 私有构造函数
  DeaultPageConfig._() {
    // 具体初始化代码
    ffFirstLoadingWidget = _loadingWidget();
    // ffNetErrorWidget = _errorWidget();
    // ffNoDataWidget = _noDataWidget();

    ffNetErrorFunc = (obj){
      return _errorWidget();
    };
    ffNoDataFunc = (obj) {
      return _noDataWidget();
    };
  }

  /**刷新代理 用于多语言*/
  static const RefreshLocalizationsDelegate refreshDelegate = RefreshLocalizations.delegate;

  /**第一次进入 */
  Widget? ffFirstLoadingWidget;

  /**网络错误 */
  DeaultConfigFunc? ffNetErrorFunc;

  /**图片加载失败全局默认图**/
  Widget? ffImageDefault;

  /**空数据 */
  DeaultConfigFunc? ffNoDataFunc;

  /**刷新配置 暂不使用 */
  Widget? refreshConfig;

  /**头部提示*/
  DeaultConfigRefreshFunc? idleText;
  DeaultConfigRefreshFunc? failedText;
  DeaultConfigRefreshFunc? completeText;
  DeaultConfigRefreshFunc? canTwoLevelText;
  DeaultConfigRefreshFunc? refreshingText;
  DeaultConfigRefreshFunc? releaseText;

  /**尾部提示*/
  DeaultConfigRefreshFunc? loadingText;
  DeaultConfigRefreshFunc? noDataText;
  DeaultConfigRefreshFunc? idleFootText;
  DeaultConfigRefreshFunc? failedFootText;
  DeaultConfigRefreshFunc? canLoadingText;

  Widget? _loadingWidget() {
    return FFTextButton(
      text: "这是假的菊花",
      color: Colors.white,
    );
  }

  /**网络错误 */
  Widget? _errorWidget() {
    return FFTextButton(
      text: "这是网络错误",
      fontColor: Colors.white,
    );
  }

  /**空数据 */
  Widget? _noDataWidget() {
    return FFTextButton(
      text: "这是空数据",
      fontColor: Colors.white,
    );
  }

// /**刷新配置 暂不使用 */
// static Widget refreshConfig(BuildContext context, Widget child) {
//   return RefreshConfiguration(
//     footerTriggerDistance: 15,
//     dragSpeedRatio: 0.91,
//     headerBuilder: () => MaterialClassicHeader(),
//     footerBuilder: () => ClassicFooter(),
//     enableLoadingWhenNoData: false,
//     enableRefreshVibrate: false,
//     enableLoadMoreVibrate: false,
//     shouldFooterFollowWhenNotFull: (state) {
//       // If you want load more with noMoreData state ,may be you should return false
//       return false;
//     },
//     child: child,
//   );
// }
}
